package P1400;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author: zhouyang
 * @descrpition:
 * @time: 2019-10-11 10:35
 */
public class P1478_陶陶摘苹果 {
    static class Node implements Comparable<Node>{
        int pay;
        int height;
        public Node(int height,int pay){
            this.pay = pay;
            this.height = height;
        }
        @Override
        public int compareTo(Node o) {
            if(this.pay == o.pay) return this.height-o.height;
            return this.pay - o.pay;
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();//苹果数
        int s = scanner.nextInt();//力气
        int a = scanner.nextInt();//椅子高度
        a += scanner.nextInt();//最大长度
        Node[] nodes = new Node[n];
        for(int i=0;i<n;++i){
            nodes[i] = new Node(scanner.nextInt(),scanner.nextInt());
        }
        scanner.close();
        Arrays.sort(nodes);
        int index = 0;
        int res = 0;
        while(s > 0){
            if(index == n || nodes[index].pay > s) break;//没有苹果 或者 没有力气了
            if(nodes[index].height <= a){
                ++res;
                s -= nodes[index].pay;
            }
            ++index;
        }
        System.out.println(res);
    }
}
